{% extends "base.html" %}

{% block content %}


<script language=javascript>
//验证数字
function isNumber(input)
{   var number = "1234567890";
    var temp;
    var j=0;
    for (var i = 0; i < input.length; i++ )
    {
        temp = input.substring(i,i+1);
        if (number.indexOf(temp) == -1)
        {
            return (false);
        }
    }
}
function verify(form){
  if(form.name.value==""){
	alert("Enter the name please!");
	form.name.focus();		
       return false;
	}
  if(form.intro.value==""){
	alert("Enter the introduce please!");
	form.intro.focus();		
       return false;
	}
	return true;
 }

</script>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td align="center">
	<form name='form1' id='form1' action="/save_agent/" method='post' onsubmit='return verify(this);'>
<table width='80%' class='grid' cellspacing='1' align='center'><tr><td colspan='10' class='title' align="center">Add agent</td></tr>
<tr valign='middle' align='left'><td class='odd' width='25%'><font color="red">*</font>Name</td>
<td class='even'><input type="text" name="name" value="" /></td></tr>
<tr valign='middle' align='left'><td class='odd' width='25%'><font color="red">*</font>Description</td>
<td class='even'><textarea name="intro" cols="50" rows="5" /></textarea></td></tr>
<tr valign='middle' align='left'><td class='odd' width='25%'>Budget</td>
<td class='even'><input type="text" name="budget" value="0" /></td></tr>
<tr valign='middle' align='left'><td class='odd' width='25%'></td>

<td class='even'>&nbsp;<input type='submit' class='button' name='submit'  id='submit' value=' Submit ' /></form></td></tr>

</table>

<table width="100%" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td align="center">
<table width='80%' class='grid' cellspacing='1' align='center'><tr><td colspan='10' class='title' align="center">agent list</td></tr>
<tr valign='middle' align='left'></tr>
  <tr valign='middle' align='left'>
  <td class='odd' width='10%'>ID</td>
  <td class='even' width='10%'>Name</td>
  <td class='odd' width='8%'>Budget</td>
  <td class='even' width='60%'>Description</td>
<td class='odd' width='12%'>Action</td>  

  </tr>
  {% for at in agent %}
 
  <tr valign='middle' align='left'>
  <td class='odd'>{{at.id}}</td>
   <td class='even'>{{at.name}}</td>
   <td class='even'>{{at.budget}}</td>
   <td class='even'>{{at.intro}}</td>
<td class='odd' ><a href="/edit_a/{{ at.id}}">Edit</a>&nbsp;&nbsp;&nbsp;<a href="/del_a/{{ at.id}}" onclick="return confirm('It will delete the agent and the customers which belongs to it .sure to do it?');">Delete</a></td>
  </tr>

  {% endfor %}

      <tr><td  class='even' colspan="10" align="right">
            
               <strong>{{ hits }}</strong>&nbsp;Records&nbsp;&nbsp;{% if is_paginated %}
                    {% ifequal current_page 1 %}First 
                    {% else %} <a href="/alist/">First</a>
                    {% endifequal %}&nbsp;&nbsp;
                    {% if has_previous %} <a href="/alist/{{ previous_page }}/">Prev</a>
                    {% else %} Prev
                    {% endif %}&nbsp;&nbsp;
                    {% if has_next %}<a href="/alist/{{ next_page }}/">Next</a>
                    {% else %}Next
                    {% endif %}&nbsp;&nbsp;
                    {% ifequal current_page pages %}Last
                    {% else %}<a href="/alist/{{ pages }}/">Last</a>
                    {% endifequal %}
                    &nbsp;&nbsp;
                    Current:<select onchange="window.location='/alist/' + this.value + '/'">
					{% for x in page_numbers %}
					<option value="{{x}}" {% ifequal x current_page %} selected="selected" {% endifequal %}>{{x}}</option>
					{% endfor %}
          </select>             &nbsp;&nbsp;
                {% endif %}              
</td></tr>
</table>

{% endblock %}